package com.ele.Servlet;

import com.ele.Pojo.PageResult;
import com.ele.Pojo.Shop;
import com.ele.Service.ShopService;
import com.ele.Service.impl.ShopServiceImpl;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 加载店铺
 */
@WebServlet("/shopList")
public class ShopListServlet extends HttpServlet {
    private ShopService shopService = new ShopServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String currentPage = req.getParameter("currentPage");
        String pageSize = req.getParameter("pageSize");

        String businessId = req.getParameter("businessId");

        PageResult<List<Shop>> list = this.shopService.shopList(currentPage,pageSize,businessId);
        String json = new Gson().toJson(list);
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().write(json);
    }
}
